package com.atstudy.byt;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2022/12/28 16:17
 * @copyright: 博为峰
 */
public class InputOutputDemo {
    public static void main(String[] args) throws IOException {
//        m1();
        FileInputStream fileInputStream = new FileInputStream("C:\\Users\\admin\\Desktop\\java29\\io\\fos.txt");
//        int i = fileInputStream.read();//读取的字节
//        System.out.println(i);
        byte[] bytes = new byte[1024];
        int len = fileInputStream.read(bytes);//读取的字节数
        String str = new String(bytes, 0, len);
        System.out.println(str);
        fileInputStream.close();
    }

    private static void m1() throws IOException {
        FileOutputStream fileOutputStream = new FileOutputStream("C:\\Users\\admin\\Desktop\\java29\\io\\fos.txt");
        fileOutputStream.write("博为峰".getBytes());
        fileOutputStream.close();
    }
}
